{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "General Ledger Extract",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "identifier" : {
      "type" : "integer",
      "description" : "Unique identifier for each file that is produced or processed by CMP"
    },
    "version" : {
      "type" : "number",
      "minimum" : 1.0,
      "maximum" : 1.0,
      "description" : "The current version of the generic extract file."
    },
    "interfaceCategory" : {
      "type" : "string",
      "enum" : [ "Payments" ],
      "description" : "CMP categorisation of the job associated with this file"
    },
    "interfaceType" : {
      "type" : "string",
      "enum" : [ "General Ledger" ],
      "description" : "Sub-categorisation of the job"
    },
    "batchDateAndTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Represents when a batch was created in CMP"
    },
    "extractDateAndTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Represents when a generic CMP file was created from a batch"
    },
    "recordCount" : {
      "type" : "integer",
      "description" : "Total number of transaction records in the extract file"
    },
    "periodCovered" : {
      "type" : "string",
      "description" : "Rpresent the month of the extract"
    },
    "payments" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/GeneralLedgerExtractPayment"
      }
    },
    "invoices" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/GeneralLedgerExtractInvoice"
      }
    },
    "bondRedemptions" : {
      "$ref" : "#/definitions/BondRedemption"
    },
    "purchases" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/GeneralLedgerExtractPurchase"
      }
    }
  },
  "required" : [ "identifier", "version", "interfaceCategory", "interfaceType", "batchDateAndTime", "extractDateAndTime", "recordCount", "periodCovered", "payments", "invoices", "bondRedemptions", "purchases" ],
  "definitions" : {
    "GeneralLedgerExtractPayment" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "paymentSource" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Source of the payment"
        },
        "nominal" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Nominal code of the payment"
        },
        "paymentDates" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/PaymentOnDate"
          }
        },
        "recurringPaymentTypes" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/RecurringPaymentType"
          }
        }
      },
      "required" : [ "paymentSource", "nominal" ]
    },
    "PaymentOnDate" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "date" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "Date of the payment"
        },
        "money" : {
          "$ref" : "#/definitions/Money"
        }
      }
    },
    "Money" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "amount" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.999999999999E10,
          "description" : "Total Amount"
        },
        "currencyCode" : {
          "type" : "string",
          "maxLength" : 3,
          "description" : "Currency code"
        }
      }
    },
    "RecurringPaymentType" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "paymentType" : {
          "type" : "string",
          "description" : "Type of the payments"
        },
        "paymentTypeDescription" : {
          "type" : "string",
          "description" : "Description of the payment type"
        },
        "paymentDates" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/RecurringPaymentOnDate"
          },
          "description" : "Dates of the Payments"
        }
      }
    },
    "RecurringPaymentOnDate" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "date" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "Date of the payments"
        },
        "money" : {
          "$ref" : "#/definitions/Money"
        },
        "isReversal" : {
          "type" : "boolean"
        }
      }
    },
    "GeneralLedgerExtractInvoice" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "nominal" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Nominal code of the invoice"
        },
        "invoiceDates" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/InvoiceDate"
          }
        }
      },
      "required" : [ "nominal" ]
    },
    "InvoiceDate" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "date" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "Date of the invoice"
        },
        "money" : {
          "$ref" : "#/definitions/Money"
        }
      }
    },
    "BondRedemption" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "nominal" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Nominal code of the invoice"
        },
        "bondRedemptionDates" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/BondRedemptionDate"
          }
        }
      },
      "required" : [ "nominal" ]
    },
    "BondRedemptionDate" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "date" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "Date of the bond redemption"
        },
        "money" : {
          "$ref" : "#/definitions/Money"
        }
      }
    },
    "GeneralLedgerExtractPurchase" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "purchaseType" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Type of Purchase"
        },
        "nominal" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Nominal code of the purchase"
        },
        "purchaseDates" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/PurchaseDate"
          }
        }
      },
      "required" : [ "purchaseType", "nominal" ]
    },
    "PurchaseDate" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "date" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "Date of the Purchase"
        },
        "money" : {
          "$ref" : "#/definitions/Money"
        }
      }
    }
  }
}